package com.chenfan.mcn.model;

import com.baomidou.mybatisplus.annotation.*;
import com.chenfan.mcn.enums.CommonSettleStatusEnum;
import com.chenfan.mcn.extension.log.FieldDesc;
import com.chenfan.mcn.constant.DictTypeCst;
import com.chenfan.mcn.constant.McnConstant;
import com.chenfan.mcn.enums.ApprovalStatusEnum;
import com.chenfan.mcn.enums.IncomeContractTypeEnum;
import com.chenfan.mcn.enums.OfflineCommissionSettleStatusEnum;
import com.chenfan.mcn.extension.log.FieldTypeEnum;
import com.chenfan.mcn.component.dict.BrandCodeTranslator;
import com.chenfan.mcn.component.dict.ContractingIdTranslator;
import com.chenfan.mcn.component.dict.CustomerIdTranslator;
import com.chenfan.mcn.component.dict.StarPlatformInfoIdTranslator;
import com.chenfan.mcn.model.base.BaseOwnerEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author tangwei
 * Date:     2021/1/19 21:02
 * Description: 收入合同
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("income_contract")
public class IncomeContract extends BaseOwnerEntity implements Serializable {

    private static final long serialVersionUID = 928666789517873605L;

    /**
     * 合同编号
     */
    @FieldDesc(value = "合同编号")
    private String contractCode;

    /**
     * 合同类型
     */
    @NotNull(message = "请选择合同类型")
    @FieldDesc(value = "合同类型", translator = IncomeContractTypeEnum.class)
    private Integer contractType;

    /**
     * 客户id
     */
    @FieldDesc(value = "客户", translator = CustomerIdTranslator.class)
    @NotNull(message = "请选择客户")
    private Long customerId;

    /**
     * 钉钉合同编号
     */
    private String dingdingContractCode;

    /**
     * 折扣审批单主键id
     */
    private Long discountId;

    /**
     * 折扣审批单编号
     */
    @FieldDesc(value = "折扣审批单编号")
    private String discountCode;

    /**
     * 年框合同主键id
     */
    private Long yearContractId;

    /**
     * 年框合同编号
     */
    @FieldDesc(value = "年框合同编号")
    private String yearContractCode;

    /**
     * 刊例总报价
     */
    @FieldDesc(value = "刊例总报价")
    private BigDecimal totalAmount;

    /**
     * 审批状态:0_待提交、1_审批中、2_审批通过、3_审批拒绝、4_已撤回、9_已作废。
     */
    @FieldDesc(value = "单据状态", translator = ApprovalStatusEnum.class)
    private Integer approvalStatus;

    /**
     * 折扣比例
     */
    @FieldDesc(value = "折扣比例")
    private BigDecimal discountRate;

    /**
     * 折扣后合同金额=刊例总报价*折扣比例
     */
    @FieldDesc(value = "折扣后合同金额")
    private BigDecimal discountAmount;

    /**
     * 商务确认合同金额
     */
    @FieldDesc(value = "商务确认合同金额")
    private BigDecimal businessAmount;

    /**
     * 最新合同金额
     */
    private BigDecimal newestAmount;

    /**
     * 形式合同类型(数据字典)
     */
    @FieldDesc(value = "形式合同类型", dictType = DictTypeCst.FORMAL_CONTRACT)
    private String formalContractType;

    /**
     * 平台下单截图
     */
    @FieldDesc(value = "平台下单截图", isArray = true)
    private String orderScreenshot;

    /**
     * 平台订单号
     */
    @FieldDesc(value = "平台订单号")
    private String platformOrderNumber;

    /**
     * 我司合同主体
     */
    private String companyContractSubject;

    /**
     * 我司合同主体id
     */
    @FieldDesc(value = "我司合同主体", translator = ContractingIdTranslator.class)
    private Long contractingId;

    /**
     * 客户开票信息id
     */
    private Long customerBillingId;

    /**
     * 客户签约主体
     */
    @FieldDesc(value = "客户签约主体")
    private String customerSignSubject;

    /**
     * 合同签订日期（精确到天）
     */
    @FieldDesc(value = "合同签订日期", format = McnConstant.SHORT_DATE_FORMAT)
    private Date signDate;

    /**
     * 合同来源（数据字典）
     */
    @FieldDesc(value = "合同来源", dictType = DictTypeCst.SOURCE_OF_CONTRACT)
    private String cooperateSource;

    /**
     * 合作品牌
     */
    @FieldDesc(value = "品牌", translator = BrandCodeTranslator.class)
    private String cooperateBrand;

    /**
     * 合作产品
     */
    @FieldDesc(value = "合作产品")
    private String cooperateProduct;

    /**
     * 上传合同
     */
    @FieldDesc(value = "上传合同", fieldType = FieldTypeEnum.FILE)
    private String contractFile;

    /**
     * 计划回款日期（精确到天）
     */
    @FieldDesc(value = "计划回款日期", format = McnConstant.SHORT_DATE_FORMAT)
    private Date plannedPaymentDate;

    /**
     * 是否为平台代下单
     */
    @FieldDesc(value = "是否为平台代下单", replace = {"否_false", "是_true"})
    private Boolean platformOrders;

    /**
     * 合作内容简介
     */
    @FieldDesc(value = "合作内容简介")
    private String cooperateContent;

    /**
     * 是否客户首单：0否；1是
     */
    private Boolean customerFirstOrder;

    /**
     * 回款状态：0未回款；1部分回款；2已回款
     */
    @FieldDesc(value = "回款状态", replace = {"未回款_0", "部分回款_1", "已回款_2"})
    private Integer payBackStatus;

    /**
     * 回款金额（元）
     */
    @FieldDesc(value = "回款金额（元）")
    private BigDecimal payBackAmount;

    /**
     * 备注
     */
    @FieldDesc(value = "备注")
    private String remark;

    /**
     * 附件-JSON字符串
     */
    private String attachmentFile;

    /**
     * 是否归档（1-否，2-是）
     */
    @FieldDesc(value = "是否归档")
    private Integer isFile;

    /**
     * 是否发放提成:1发放；0不发放
     */
    private Boolean issueCommission;

    /**
     * 是否业绩记录：1是；0否
     */
    private Boolean trackRecord;
    /**
     * 开票形式：0无需开票；1开票待定；2开票
     */
    @FieldDesc(value = "开票形式", replace = {"无需开票_0", "开票待定_1", "开票_2"})
    private Integer invoiceForm;

    /**
     * 开票类型：普票；专票
     */
    @FieldDesc(value = "开票类型")
    private String invoiceType;

    /**
     * 发票内容
     */
    @FieldDesc(value = "发票内容")
    private String invoiceContent;

    /**
     * 发票备注
     */
    @FieldDesc(value = "发票备注")
    private String invoiceRemark;

    /**
     * 是否业绩共享：0否；1是
     */
    @FieldDesc(value = "是否业绩共享", replace = {"否_0", "是_1"})
    private Integer performanceShare;


    /**
     * 业绩共享人id
     */
    private Long performanceSharerId;

    /**
     * 业绩共享人名称
     */
    @FieldDesc(value = "业绩共享人")
    private String performanceSharerName;

    /**
     * 部门负责人id
     */
    private Long departmentHeaderId;

    /**
     * 部门负责人名称
     */
    private String departmentHeaderName;


    /**
     * 直播金额
     */
    @FieldDesc(value = "直播金额")
    private BigDecimal liveAmount;

    /**
     * 广告金额
     */
    @FieldDesc(value = "广告金额")
    private BigDecimal adAmount;

    /**
     * 预估总金额
     */
    private BigDecimal expectedAmount;


    /**
     * ---------------------直播合同Start---------------------
     */

    /**
     * 保证金
     */
    private BigDecimal earnestMoney;

    /**
     * 合作类型
     */
    @FieldDesc(value = "合作类型", dictType = DictTypeCst.COOPERATION_TYPE)
    private String cooperationType;

    /**
     * 主播
     */
    @FieldDesc(value = "主播", translator = StarPlatformInfoIdTranslator.class)
    private Long starPlatformInfoId;

    /**
     * 类目
     */
    @FieldDesc(value = "类目", dictType = DictTypeCst.LIVE_CONTRACT_CATEGORY)
    private String liveContractCategory;

    /**
     * 合同履约有效期-开始
     */
    @FieldDesc(value = "合同履约有效期-开始")
    private Date liveDate;

    /**
     * 合同履约有效期-结束
     */
    @FieldDesc(value = "合同履约有效期-结束")
    private Date liveDateEnd;

    /**
     * 是否含广告：0-否、1-是
     */
    @TableField("contains_advertising")
    @FieldDesc(value = "是否含广告", replace = {"否_0", "是_1"})
    private Integer containsAdvertising;

    /**
     * 线上佣金比例
     */
    @FieldDesc(value = "线上佣金比例")
    @TableField("online_commission_rate")
    private String onlineCommissionRate;

    /**
     * 线下佣金比例
     */
    @FieldDesc(value = "线下佣金比例")
    @TableField("offline_commission_rate")
    private String offlineCommissionRate;

    /**
     * 坑位费
     */
    @FieldDesc(value = "坑位费")
    @TableField("pit_fee_amount")
    private BigDecimal pitFeeAmount;

    /**
     * 保ROI服务费
     */
    @FieldDesc(value = "保ROI服务费")
    @TableField("roi_service_fee")
    private BigDecimal roiServiceFee;

    /**
     * 是否保ROI
     */
    @FieldDesc(value = "是否保ROI", replace = {"否_0", "是_1"})
    @TableField("is_roi")
    private Integer isRoi;

    /**
     * ROI比例
     */
    @FieldDesc(value = "ROI比例", format = "1:%s")
    @TableField("roi_rate")
    private String roiRate;

    /**
     * 线下佣金应收金额
     */
    @FieldDesc(value = "线下佣金应收金额")
    @TableField("offline_commission_amount")
    private BigDecimal offlineCommissionAmount;


    /**
     * 线下佣金-结算状态：0待结算、1结算中、2待回款、3部分回款、4已回款
     */
    @FieldDesc(value = "线下佣金结算状态", translator = OfflineCommissionSettleStatusEnum.class)
    @TableField("offline_commission_settle_status")
    private Integer offlineCommissionSettleStatus;

    /**
     * 线下佣金-已回款金额
     */
    @FieldDesc(value = "线下佣金-已回款金额")
    @TableField("offline_commission_payback_amount")
    private BigDecimal offlineCommissionPaybackAmount;


    /**---------------------直播合同End---------------------*/

    /**
     * 最近回款日期
     */
    @FieldDesc(value = "最近回款日期", format = "yyyy-MM-dd")
    private Date payBackDate;


    /**
     * 归档状态(0-待盖章，1-待归档，2-已归档)
     */
    @FieldDesc(value = "归档状态", replace = {"待盖章_0", "待归档_1", "已归档_2"})
    private Integer archivingStatus;

    /**
     * 归档编号
     */
    @FieldDesc("归档编号")
    private String archivingCode;

    /**
     * 业绩共享人部门id
     */
    private Long performanceSharerDepartmentId;

    /**
     * 合同标签
     */
    @FieldDesc(value = "合同标签", dictType = DictTypeCst.INCOME_CONTRACT_TAG)
    private String contractTag;

    /**
     * 目标销售额
     */
    private BigDecimal targetSalesAmt;

    /**
     * 保ROI广告收入
     */
    private BigDecimal roiAdvAmt;

    /**
     * 目标销售额备注
     */
    private String targetSalesRemark;

    /**
     * 不保ROI广告收入
     */
    private BigDecimal noroiAdvAmt;

    /**
     * 保ROI直播收入
     */
    private BigDecimal roiLiveAmt;

    /**
     * 不保ROI直播收入
     */
    private BigDecimal noroiLiveAmt;

    /**
     * 保ROI其他收入
     */
    private BigDecimal roiOhterAmt;

    /**
     * 不保ROI其他收入
     */
    private BigDecimal noroiOhterAmt;

    /**
     * 佣金备注
     */
    private String commissionPercentRemark;

    /**
     * 合同账期
     */
    private Integer paymentDay;

    /**
     * 保ROI收入广告收益—是否有广告收益
     */
    @FieldDesc(value = "保ROI收入广告收益—是否有广告收益", replace = {"否_0", "是_1"})
    private Integer roiAdvAmtEquity;

    /**
     * 不保ROI收入广告收益—是否有广告收益
     */
    @FieldDesc(value = "不保ROI收入广告收益—是否有广告收益", replace = {"否_0", "是_1"})
    private Integer noroiAdvAmtEquity;

    /**
     * 直播提成结算状态：0未结算 2已结算
     */
    @FieldDesc(value = "直播提成结算状态", translator = CommonSettleStatusEnum.class)
    private Integer liveCommissionSettleStatus;

    /**
     * 是否下单至我司后台：0否、1是
     */
    @FieldDesc(value = "是否下单至我司后台", replace = {"否_0","是_1"})
    private Integer inSystemAdmin;
}
